<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		
		function run() {
			now = new Date();

			yuandan = new Date("2019-01-01 0:0:0");

			diff = (yuandan.getTime()-now.getTime())/1000;

			day = Math.floor(diff/86400);

			document.write(day+"天-");

			diff = diff%86400;

			hour = Math.floor(diff/3600);

			document.write(hour+"小时-");

			diff = diff%3600;

			min = Math.floor(diff/60);

			document.write(min+"分钟-");

			second = parseInt(diff%60);

			document.write(second+"秒<br>");
		}

		// setInterval(run,1000);
		num=0;
		for (var i = 1900; i <=2018; i++) {
			if((i%4==0 && i%100!=0) || i%400==0){
				num++;
			}
		}

		// document.write(num)

		userList = ['小明','小红','小花','小森'];

		index = Math.ceil(Math.random()*userList.length)-1;

		// document.write(userList[index])

		arr = [[18,6],[20,5],[56,3],[789,1]];


		total = 0;

		num = 0;


		for (var i in arr) {
			total += arr[i][0]*arr[i][1];
			num += arr[i][1];
		}

		document.write(total+"<br>");
		document.write( Math.round(total/num*100)/100);


		function run(argument) {
			location.replace('http://www.baidu.com')
		}

		setInterval(run,3000)
		
	</script>
</body>
	<p onclick="">点我</p>
</html>